package com.prs.crm.service.hr.impl;

import java.util.ArrayList;
import java.util.Collection;

import java.util.List;

import com.prs.crm.dao.hr.CheckDao;
import com.prs.crm.domain.hr.Check;
import com.prs.crm.domain.hr.Person;

import com.prs.crm.service.hr.CheckService;
import com.prs.crm.service.impl.BaseServiceImpl;


public class CheckServiceImpl extends BaseServiceImpl<Check,CheckDao> implements CheckService{

	@Override
	public List<Check> getAllCheck() {
		// TODO Auto-generated method stub
		return this.getDao().getAllCheck();
	}

	@Override
	public void saveOrUpdate(Check check) {
		this.getDao().saveOrUpdate(check);
		
	}


	@Override
	public boolean existSameCheck(String name, String date) {
		// TODO Auto-generated method stub
		boolean flag =false;
		List<Check> checks = this.getDao().getChecks(name, date);
		if(checks.size()!= 0) {
			flag = true;
		}
		    return flag;
	}

	@Override
	public Check getCheckByname(String name, String date) {
		// TODO Auto-generated method stub
		return this.getDao().getCheckByname(name, date);
	}


	@Override
	public List<Check> getChecks(String name, String date) {
		// TODO Auto-generated method stub
		return this.getDao().getChecks(name, date);
	}

	@Override
	public Collection<Person> convertIdsToPersons(Collection<Integer> ids) {
		Collection<Person> persons = new ArrayList<Person>();
		for(Integer id : ids){
			Person person = new Person();
			person.setId(id);
			persons.add(person);
		}
		return persons;
	}


	@Override
	public List<Check> getCheckByPersonInMonth(String name,
			String months) {
		// TODO Auto-generated method stub
		return this.getDao().getCheckByPersonInMonth(name, months);
	}

	

	@Override
	public Collection<Object[]> getCheckByPersonydm(Collection<Person> persons,
			String date) {
		// TODO Auto-generated method stub
		return this.getDao().getCheckByPersonydm(persons, date);
	}
	
	public Collection<Check> getPersonChecksInMonth(Integer userId,String month)
	{
		return this.getDao().getPersonChecksInMonth(userId, month);
	}

}
